package memnto.source;

/**
 * @author Chen Guang
 * @date 2019/4/17 0017 上午 9:49
 */
public class Test {
    public static void main(String[] args) {
        //发起人设置初始状态
        Originator originator = new Originator();
        originator.setState("ON");
        originator.show();

        //创建一个保管者并且发起人创建一个备忘录给保管者
        CareTaker careTaker = new CareTaker();
        Memento memento = originator.createMemento();
        careTaker.setMemento(memento);

        //发起人改变初始状态
        originator.setState("OFF");
        originator.show();

        //将备忘录设置给发起人恢复到初始数据
        originator.setMemento(memento);
        originator.show();
    }
}
